<template>
  <div class="doctor-manage">
    <!-- 标题和顶部按钮 -->
    <div style="margin-bottom: 15px;">
      <span style="font-size: 25px;font-weight: bold;">医生管理</span>
      <span style="float: right;">
          <el-button type="primary" @click="exportDoctors">导出</el-button>
          <el-button type="warning" @click="handleImport">导入</el-button>
      </span>
    </div>
    
    <!-- 第一个卡片：搜索区域 -->
    <el-card class="box-card" shadow="hover" style="margin-bottom: 20px;">
      <template #header>
        <div class="card-header">
          <span>搜索条件</span>
          <div style="float: right;">
            <el-button type="success" @click="goAddDoctor">新增医生信息</el-button>
            <el-button type="danger" :disabled="multipleSelection.length === 0" @click="handleBatchDelete">批量删除</el-button>
          </div>
        </div>
      </template>
      <div class="search-bar">
        <el-cascader
          v-model="searchForm.DepartmentId"
          :options="departmentCascaderOptions"
          placeholder="请选择科室"
          :props="{ checkStrictly: false, emitPath: false, value: 'value', label: 'label', children: 'children' }"
          clearable
          filterable
          style="width: 180px;"
        />
        <el-input v-model="searchForm.DoctorName" placeholder="请输入医生姓名" style="width: 200px; margin: 0 10px;" />
        <el-button type="primary" @click="fetchDoctors">搜索</el-button>
        <el-button type="warning" @click="zero">重置</el-button>
      </div>
    </el-card>
    
    <!-- 第二个卡片：数据表格 -->
    <el-card class="box-card" shadow="hover">
      <template #header>
        <div class="card-header">
          <span>医生列表</span>
        </div>
      </template>
      <el-table :data="doctorList" style="width: 100%;" @selection-change="handleSelectionChange" ref="doctorTable">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="doctorName" label="医生姓名" />
        <el-table-column label="医生头像">
          <template #default="scope">
            <el-avatar :src="scope.row.photo" />
          </template>
        </el-table-column>
        <el-table-column prop="campusName" label="院区" />
        <el-table-column prop="jobTitle" label="职称" />
        <el-table-column prop="departmentName" label="科室" />
        <el-table-column label="标签">
          <template #default="scope">
            <el-tag v-for="label in scope.row.labels" :key="label.id" style="margin-right: 4px;">{{ label.label }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="briefly" label="医生简介" :show-overflow-tooltip="true" />
        <el-table-column label="操作" width="100">
          <template #default="scope">
            <el-button size="mini" @click="editDoctor(scope.row)" circle >
              <el-icon><Edit /></el-icon>
            </el-button>
            <el-button size="mini" type="danger" @click="deleteDoctor(scope.row)" circle >
              <el-icon><Delete /></el-icon>
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        :current-page="pagination.PageIndex"
        :page-size="pagination.PageSize"
        :total="pagination.totaCount"
        @current-change="handlePageChange"
        @size-change="handleSizeChange"
        layout="total, sizes, prev, pager, next, jumper"
        :page-sizes="[3, 6, 9, 12]"
        style="margin-top: 20px; text-align: right;"
      />
    </el-card>
    
    <!-- 导入对话框 -->
    <el-dialog v-model="importDialogVisible" title="导入医生信息" width="500px" @close="resetImportDialog">
      <div class="import-dialog-content">
        <div class="step-container">
          <div class="step-item">
            <div class="step-number">1</div>
            <div class="step-text">
              <h4>下载模板</h4>
              <p>请先下载导入模板，按照格式填写医生信息</p>
              <el-button type="primary" @click="downloadTemplate">下载模板</el-button>
            </div>
          </div>
          
          <div class="step-divider"></div>
          
          <div class="step-item">
            <div class="step-number">2</div>
            <div class="step-text">
              <h4>上传文件</h4>
              <p>选择填写好的Excel文件进行上传</p>
              <el-upload
                class="upload-demo"
                :action="'/'"
                :auto-upload="false"
                :on-change="handleFileChange"
                :limit="1"
                :file-list="fileList"
                :before-upload="beforeUpload"
                accept=".xlsx,.xls"
              >
                <template #trigger>
                  <el-button type="primary">选择文件</el-button>
                </template>
                <el-button style="margin-left: 10px;" type="success" @click="submitUpload" :disabled="!hasSelectedFile">上传</el-button>
                <template #tip>
                  <div class="el-upload__tip">请上传Excel文件(.xlsx或.xls格式)</div>
                </template>
              </el-upload>
            </div>
          </div>
        </div>
      </div>
    </el-dialog>
    
    <!-- 导入结果对话框 -->
    <el-dialog v-model="importResultVisible" title="导入结果" width="500px">
      <div class="import-result-content">
        <div class="result-summary">
          <el-alert
            :type="importResult.failedCount > 0 ? 'warning' : 'success'"
            :title="importResult.failedCount > 0 ? '部分导入成功' : '导入成功'"
            :description="`总计${importResult.totalRows}条数据，成功${importResult.successCount}条，失败${importResult.failedCount}条`"
            :closable="false"
            show-icon
          />
        </div>
        
        <div v-if="importResult.failedCount > 0" class="error-list">
          <h4>错误详情：</h4>
          <el-alert
            v-for="(error, index) in importResult.errorMessages"
            :key="index"
            type="error"
            :title="error"
            :closable="false"
            style="margin-bottom: 10px;"
          />
        </div>
      </div>
      <template #footer>
        <el-button type="primary" @click="importResultVisible = false">确定</el-button>
      </template>
    </el-dialog>
    
    <!-- 编辑医生弹窗 -->
    <el-dialog v-model="editDialogVisible" title="编辑医生信息" width="600px" @close="resetEditForm">
      <el-form :model="editForm" ref="editFormRef" label-width="100px" :rules="editRules">
        <el-form-item label="医生姓名" prop="doctorName">
          <el-input v-model="editForm.doctorName" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="上传照片" prop="photo">
          <el-upload
            class="avatar-uploader-circle"
            :show-file-list="false"
            :action="'/'"

            :http-request="customUpload"
          >
            <template #default>
              <div class="avatar-wrapper">
                <img v-if="editForm.photo" :src="editForm.photo" class="avatar-circle" />
                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                <div v-if="editForm.photo" class="avatar-mask" @click.stop="removePhoto">
                  <i class="el-icon-delete"></i>
                </div>
              </div>
            </template>
          </el-upload>
        </el-form-item>
        <el-form-item label="所属院区" prop="campusId">
          <el-select v-model="editForm.campusId" placeholder="请选择院区">
            <el-option v-for="item in campusOptions" :key="item.id" :label="item.campusName" :value="item.id" />
          </el-select>
        </el-form-item>
        <el-form-item label="所属科室" prop="departmentId">
          <el-cascader
            v-model="editForm.departmentId"
            :options="departmentCascaderOptions"
            placeholder="请选择科室"
            :props="{ checkStrictly: false, emitPath: false, value: 'value', label: 'label', children: 'children' }"
            clearable
            filterable
            style="width: 100%;"
          />
        </el-form-item>
        <el-form-item label="医生职称" prop="jobTitleId">
          <el-select v-model="editForm.jobTitleId" placeholder="请选择医生职称">
            <el-option v-for="item in jobTitleOptions" :key="item.id" :label="item.jobTitle" :value="item.id" />
          </el-select>
        </el-form-item>
        <el-form-item label="医生标签" prop="laberIds">
          <el-select v-model="editForm.laberIds" multiple placeholder="请选择">
            <el-option v-for="item in labelOptions" :key="item.id" :label="item.label" :value="item.id" />
          </el-select>
        </el-form-item>
        <el-form-item label="挂号费" prop="copayfee">
          <el-input-number v-model="editForm.copayfee" :min="0" />
        </el-form-item>
        <el-form-item label="诊查费" prop="consultationfee">
          <el-input-number v-model="editForm.consultationfee" :min="0" />
        </el-form-item>
        <el-form-item label="医生简介" prop="briefly">
          <el-input v-model="editForm.briefly" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="医生状态" prop="status">
          <el-switch v-model="editForm.status" />
        </el-form-item>
      </el-form>
      <template #footer>
        <el-button @click="editDialogVisible = false">取消</el-button>
        <el-button type="primary" @click="onEditSubmit">保存</el-button>
      </template>
    </el-dialog>
  </div>
</template>

<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue'
import { ElMessage, ElLoading } from 'element-plus'
import {axioswmedical} from '@/http/axiosWrtie'
import {axiosimg} from '@/http/axiosWrtie'
import {axiosrmedical} from '@/http/axiosRead'
import { useRouter } from 'vue-router'
const router = useRouter()
const goAddDoctor = () => {
  router.push({ name: 'DoctorAdd' }) // 路由名需和你的路由配置一致
}

// 科室级联下拉选项
const departmentCascaderOptions = ref<any[]>([])

// 获取科室级联列表
const fetchDepartments = async () => {
  try {
    const res = await axiosrmedical.get('/Department/GetAllDepartments')
    if (res.data.code === 200) {
      departmentCascaderOptions.value = res.data.data.map((item: any) => ({
        id: item.id,
        label: item.departmentName,
        value: item.id,
        children: (item.children || []).map((child: any) =>
          typeof child === 'object' ? {
            id: child.id,
            label: child.departmentName,
            value: child.id
          } : {
            label: child,
            value: child
          }
        )
      }))
    } else {
      ElMessage.error(res.data.msg || '获取科室失败')
    }
  } catch (e) {
    ElMessage.error('网络错误')
  }
}


// 搜索表单
const searchForm = reactive({
  DepartmentId: null,
  DoctorName: '',
})

// 分页
const pagination = reactive({
  PageIndex: 1,
  PageSize: 3,
  totaCount: 0
})

// 医生列表
const doctorList = ref([])

// 多选相关
const multipleSelection = ref<any[]>([])
const doctorTable = ref()
const handleSelectionChange = (val: any[]) => {
  multipleSelection.value = val
}
const handleBatchDelete = async () => {
  if (multipleSelection.value.length === 0) {
    ElMessage.warning('请先选择要删除的医生')
    return
  }
  try {
    const ids = multipleSelection.value.map(item => item.id)
    const res = await axioswmedical.put('/Doctor/BatchDeleteDoctor', {
      doctorIds: ids
    })
    if (res.data.code === 200) {
      ElMessage.success(res.data.msg || '批量删除成功')
      fetchDoctors()
      // 清空选中
      const table = (doctorTable.value as any)
      if (table) table.clearSelection()
    } else {
      ElMessage.error(res.data.msg || '批量删除失败')
    }
  } catch (e) {
    ElMessage.error('网络错误')
  }
}



// 获取医生列表
const fetchDoctors = async () => {
  try {
    const res = await axiosrmedical.get('/Doctor/SearchDoctor', {params:{
      DepartmentId: searchForm.DepartmentId,
      DoctorName: searchForm.DoctorName,
      PageIndex: pagination.PageIndex,
      PageSize: pagination.PageSize
    }})
    if (res.data.code === 200) {
      doctorList.value = res.data.pageData
      pagination.totaCount = res.data.totaCount
    } else {
      ElMessage.error(res.data.msg || '获取医生列表失败')
    }
  } catch (e) {
    ElMessage.error('网络错误')
  }
}

// 分页切换
const handlePageChange = (page: number) => {
  pagination.PageIndex = page
  fetchDoctors()
}
const handleSizeChange = (size: number) => {
  pagination.PageSize = size
  pagination.PageIndex = 1
  fetchDoctors()
}

// 编辑操作
const editDoctor = async (row: any) => {
  await fetchEditOptions()
  // 赋值，类型转换保证下拉和表单正确显示
  Object.assign(editForm, {
    doctorId: row.id,
    doctorName: row.doctorName,
    photo: row.photo,
    campusId: row.campusId != null ? String(row.campusId) : '',
    departmentId: row.departmentId != null ? String(row.departmentId) : '',
    jobTitleId: row.jobTitleId != null ? String(row.jobTitleId) : '',
    copayfee: Number(row.copayfee),
    consultationfee: Number(row.consultationfee),
    briefly: row.briefly,
    laberIds: row.labels ? row.labels.map((l:any)=>String(l.id)) : [],
    status: row.status === true || row.status === 1 || row.status === '1'
  })
  editDialogVisible.value = true
}
const deleteDoctor = async (row: any) => {
  try {
    const res = await axioswmedical.put('/Doctor/BatchDeleteDoctor', {
      doctorIds: [row.id]
    })
    if (res.data.code === 200) {
      ElMessage.success(res.data.msg || '删除成功')
      fetchDoctors()
    } else {
      ElMessage.error(res.data.msg || '删除失败')
    }
  } catch (e) {
    ElMessage.error('网络错误')
  }
}

// 选项数据
const campusOptions = ref<any[]>([])
const jobTitleOptions = ref<any[]>([])
const labelOptions = ref<any[]>([])

// 获取下拉选项数据
const fetchEditOptions = async () => {
  try {
    // 院区
    const campusRes = await axiosrmedical.get('/Campus/GetCampus')
    if (campusRes.data.code === 200) {
      campusOptions.value = campusRes.data.data.map((item: any) => ({
        id: String(item.id),
        campusName: item.campusName
      }))
    }
    // 职称
    const jobTitleRes = await axiosrmedical.get('/JobTitle/GetJobTitle')
    if (jobTitleRes.data.code === 200) {
      jobTitleOptions.value = jobTitleRes.data.data.map((item: any) => ({
        id: String(item.id),
        jobTitle: item.jobTitle
      }))
    }
    // 标签
    const labelRes = await axiosrmedical.get('/Label/GetLabel')
    if (labelRes.data.code === 200) {
      labelOptions.value = labelRes.data.data.map((item: any) => ({
        id: String(item.id),
        label: item.label
      }))
    }
    // 科室（级联）- 使用已存在的departmentCascaderOptions
    // 科室数据已经在fetchDepartments中获取，这里不需要重复获取
  } catch (e) {
    ElMessage.error('下拉选项获取失败')
  }
}

// 编辑弹窗相关
const editDialogVisible = ref(false)
const editFormRef = ref()
const editForm = reactive({
  doctorId: null,
  doctorName: '',
  photo: '',
  campusId: '',
  departmentId: '',
  jobTitleId: '',
  copayfee: 0,
  consultationfee: 0,
  briefly: '',
  laberIds: [],
  status: true
})
const editRules = {
  doctorName: [{ required: true, message: '请输入医生姓名', trigger: 'blur' }],
  photo: [{ required: true, message: '请上传照片', trigger: 'change' }],
  campusId: [{ required: true, message: '请选择院区', trigger: 'change' }],
  departmentId: [{ required: true, message: '请选择科室', trigger: 'change' }],
  jobTitleId: [{ required: true, message: '请选择医生职称', trigger: 'change' }],
  copayfee: [{ required: true, message: '请输入挂号费', trigger: 'blur' }],
  consultationfee: [{ required: true, message: '请输入诊查费', trigger: 'blur' }],
  briefly: [{ required: true, message: '请输入简介', trigger: 'blur' }]
}

const customUpload = async (option: any) => {
  const formData = new FormData()
  formData.append('file', option.file)
  try {
    const res = await axiosimg.post('/FileUpload/UploadFile', formData, {
      headers: { 'Content-Type': 'multipart/form-data' }
    })
    let url = res.data
    if (typeof url === 'object' && url.url) url = url.url
    editForm.photo = url
    ElMessage.success('上传成功')
    option.onSuccess(res.data)
  } catch (e) {
    ElMessage.error('上传失败')
    option.onError(e)
  }
}
const removePhoto = () => {
  editForm.photo = ''
}

const resetEditForm = () => {
  editForm.doctorId = null
  editForm.doctorName = ''
  editForm.photo = ''
  editForm.campusId = ''
  editForm.departmentId = ''
  editForm.jobTitleId = ''
  editForm.copayfee = 0
  editForm.consultationfee = 0
  editForm.briefly = ''
  editForm.laberIds = []
  editForm.status = true
}
const onEditSubmit = () => {
  editFormRef.value.validate(async (valid: boolean) => {
    if (!valid) return
    try {
      const res = await axioswmedical.put('/Doctor/UpdateDoctor', {
        doctorId: editForm.doctorId,
        doctorName: editForm.doctorName,
        photo: editForm.photo,
        campusId: editForm.campusId,
        departmentId: editForm.departmentId,
        jobTitleId: editForm.jobTitleId,
        copayfee: editForm.copayfee,
        consultationfee: editForm.consultationfee,
        briefly: editForm.briefly,
        laberIds: editForm.laberIds,
        status: editForm.status
      })
      if (res.data.code === 200) {
        ElMessage.success(res.data.msg || '编辑成功')
        editDialogVisible.value = false
        fetchDoctors()
      } else {
        ElMessage.error(res.data.msg || '编辑失败')
      }
    } catch (e) {
      ElMessage.error('网络错误')
    }
  })
}

// 切换状态
const changeStatus = async (row: any) => {
  try {
    const res = await axioswmedical.put('/Doctor/UpdateDoctorStatus', {
      doctorId: row.id,
    })
    if (res.data.code === 200) {
      ElMessage.success(res.data.msg || '状态更新成功')
      fetchDoctors()
    } else {
      ElMessage.error(res.data.msg || '状态更新失败')
    }
  } catch (e) {
    ElMessage.error('网络错误')
  }
}

//重置
const zero=()=>{
searchForm.DepartmentId=null;
searchForm.DoctorName="";
fetchDoctors()
}

// 导出医生信息
const exportDoctors = async () => {
  try {
    // 使用当前搜索条件进行导出
    const response = await axioswmedical.get('/DoctorImport/Export', {
      params: {
        doctorName: searchForm.DoctorName || '',
        departmentId: searchForm.DepartmentId || 0
      },
      responseType: 'blob' // 设置响应类型为blob
    })
    
    // 创建Blob对象
    const blob = new Blob([response.data], { 
      type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' 
    })
    
    // 创建下载链接
    const link = document.createElement('a')
    const url = window.URL.createObjectURL(blob)
    
    // 设置下载属性
    const currentDate = new Date().toISOString().split('T')[0]
    link.href = url
    link.download = `医生信息_${currentDate}.xlsx`
    
    // 触发下载
    document.body.appendChild(link)
    link.click()
    
    // 清理
    window.URL.revokeObjectURL(url)
    document.body.removeChild(link)
    
    ElMessage.success('导出成功')
  } catch (error) {
    console.error('导出失败:', error)
    ElMessage.error('导出失败')
  }
}

// 导入相关变量和方法
const importDialogVisible = ref(false)
const fileList = ref<any[]>([])
const uploadFile = ref<File | null>(null)
const hasSelectedFile = ref(false)

// 处理导入按钮点击
const handleImport = () => {
  importDialogVisible.value = true
  fileList.value = []
  uploadFile.value = null
  hasSelectedFile.value = false
}

// 重置导入对话框
const resetImportDialog = () => {
  fileList.value = []
  uploadFile.value = null
  hasSelectedFile.value = false
}

// 下载导入模板
const downloadTemplate = async () => {
  try {
    // 使用axioswmedical而不是axiosrmedical
    const response = await axioswmedical.get('/DoctorImport/DownloadTemplate', {
      responseType: 'blob'
    })
    
    // 检查响应内容类型
    const contentType = response.headers['content-type']
    if (contentType && contentType.includes('application/json')) {
      // 如果返回的是JSON（可能是错误信息），则解析并显示
      const reader = new FileReader()
      reader.onload = function() {
        try {
          const jsonResponse = JSON.parse(reader.result as string)
          ElMessage.error(jsonResponse.msg || '模板下载失败')
        } catch (e) {
          ElMessage.error('模板下载失败')
        }
      }
      reader.readAsText(response.data)
      return
    }
    
    // 创建Blob对象
    const blob = new Blob([response.data], { 
      type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' 
    })
    
    // 创建下载链接
    const link = document.createElement('a')
    const url = window.URL.createObjectURL(blob)
    
    // 设置下载属性
    link.href = url
    link.download = '医生导入模板.xlsx'
    
    // 触发下载
    document.body.appendChild(link)
    link.click()
    
    // 清理
    window.URL.revokeObjectURL(url)
    document.body.removeChild(link)
    
    ElMessage.success('模板下载成功')
  } catch (error) {
    console.error('模板下载失败:', error)
    ElMessage.error('模板下载失败')
  }
}

// 上传前验证
const beforeUpload = (file: File) => {
  // 检查文件类型
  const isExcel = file.type === 'application/vnd.ms-excel' || 
                 file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' ||
                 file.name.endsWith('.xlsx') || 
                 file.name.endsWith('.xls')
  
  if (!isExcel) {
    ElMessage.error('只能上传Excel文件!')
    return false
  }
  
  // 检查文件大小（限制为10MB）
  const isLt10M = file.size / 1024 / 1024 < 10
  if (!isLt10M) {
    ElMessage.error('文件大小不能超过10MB!')
    return false
  }
  
  return true
}

// 处理文件选择变化
const handleFileChange = (file: any) => {
  if (file && file.raw) {
    uploadFile.value = file.raw
    hasSelectedFile.value = true
    console.log('选择的文件:', file.raw.name, file.raw.type, file.raw.size)
    
    // 确保fileList包含当前选择的文件
    if (!fileList.value.some(f => f.uid === file.uid)) {
      fileList.value = [file]
    }
  } else {
    // 如果文件被移除
    hasSelectedFile.value = false
    uploadFile.value = null
  }
}

// 提交上传
const submitUpload = () => {
  if (!hasSelectedFile.value || !uploadFile.value) {
    ElMessage.warning('请先选择文件')
    return
  }
  
  // 调用上传方法
  uploadExcel()
}

// 导入结果对话框数据
const importResultVisible = ref(false)
const importResult = ref<{
  totalRows: number,
  successCount: number,
  failedCount: number,
  errorMessages: string[]
}>({
  totalRows: 0,
  successCount: 0,
  failedCount: 0,
  errorMessages: []
})

// 上传Excel文件
const uploadExcel = async () => {
  if (!uploadFile.value) {
    ElMessage.warning('请先选择文件')
    return
  }
  
  // 检查文件类型
  const fileType = uploadFile.value.type
  const validTypes = [
    'application/vnd.ms-excel',
    'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
    'application/octet-stream' // 有时Excel文件可能被识别为这种类型
  ]
  
  if (!validTypes.includes(fileType) && 
      !uploadFile.value.name.endsWith('.xlsx') && 
      !uploadFile.value.name.endsWith('.xls')) {
    ElMessage.error('请上传Excel格式的文件')
    console.error('文件类型不正确:', fileType)
    return
  }
  
  const formData = new FormData()
  formData.append('file', uploadFile.value)
  
  try {
    // 显示加载状态
    const loading = ElLoading.service({
      lock: true,
      text: '正在导入...',
      background: 'rgba(0, 0, 0, 0.7)'
    })
    
    const response = await axioswmedical.post('/DoctorImport/Import', formData, {
      headers: { 'Content-Type': 'multipart/form-data' }
    })
    
    // 关闭加载状态
    loading.close()
    
    console.log('导入响应:', response.data)
    
    if (response.data) {
      // 关闭导入对话框
      importDialogVisible.value = false
      
      // 设置导入结果
      if (response.data.result) {
        importResult.value = {
          totalRows: response.data.result.totalRows || 0,
          successCount: response.data.result.successCount || 0,
          failedCount: response.data.result.failedCount || 0,
          errorMessages: response.data.result.errorMessages || []
        }
        
        // 显示导入结果对话框
        importResultVisible.value = true
      } else {
        ElMessage.success(response.data.message || '导入成功')
      }
      
      // 刷新医生列表
      fetchDoctors()
    } else {
      console.error('导入失败响应:', response)
      ElMessage.error('导入失败，请检查文件格式是否正确')
    }
  } catch (error) {
    console.error('导入失败:', error)
    ElMessage.error('导入失败，请检查网络连接或联系管理员')
  }
}

// 页面加载时获取科室和医生
onMounted(() => {
  fetchDepartments()
  fetchDoctors()
})
</script>

<style scoped>
.doctor-manage {
  padding: 24px;
  background: #f5f7fa;
}
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar-circle {
  width: 100px;
  height: 100px;
  max-width: 100px;
  max-height: 100px;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}
.box-card {
  margin-bottom: 20px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.card-header span {
  font-weight: bold;
  font-size: 16px;
}

/* 导入对话框样式 */
.import-dialog-content {
  padding: 10px;
}
.step-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.step-item {
  display: flex;
  align-items: flex-start;
  gap: 15px;
}
.step-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background-color: #409EFF;
  color: white;
  font-weight: bold;
}
.step-text h4 {
  margin-top: 0;
  margin-bottom: 10px;
}
.step-divider {
  height: 1px;
  background-color: #EBEEF5;
  margin: 0 0 0 15px;
}
.upload-demo {
  margin-top: 15px;
}

/* 导入结果对话框样式 */
.import-result-content {
  padding: 10px 0;
}
.result-summary {
  margin-bottom: 20px;
}
.error-list {
  margin-top: 20px;
}
.error-list h4 {
  margin-bottom: 15px;
  color: #f56c6c;
  font-weight: bold;
}
</style>